window.onload = function() {
    var lists = document.querySelector('.list .list_s .lt_bd');
    var xhr = new XMLHttpRequest();
    xhr.open('get', 'http://localhost:8888/goods/list?pagesize=25');
    xhr.send();
    xhr.onreadystatechange = function() {
        if(xhr.readyState === 4) {
            if(parseInt(xhr.status / 100) === 2) {
                res = xhr.responseText;
                res = JSON.parse(res);
                var {code, list} = res;
                if(code === 1) {
                    console.log(list.length);
                    var str = '<ul>';
                    for(var x = 0; x < list.length; x++) {
                        str += `
                        <li>
                            <a href="./detail.html?id=${list[x].goods_id}">
                                <img src="${list[x].img}" alt="">
                                <p class="r">${list[x].t}</p>
                                <i>￥${list[x].jp}</i>
                                <span>卷</span>
                            </a>
                        </li>
                        `
                    }
                    str += '</ul>'
                    lists.innerHTML = str;
                }
            }
        }
    }
}